package components.fte
{

    /**
     *FTE 值格式化
     * @author zn
     *
     */
    public class FTEStrFormat
    {
        /**
         *格式化
         * @param str
         * @return
         *
         */
        public static function format(str:String):XML
        {
            var xml:XML;
            try
            {
                xml = XML(str);
            }
            catch (error:Error)
            {
                var errorStr:String = "FTEStrFormat.format错误，无法转换为xml:" + str;
                trace(errorStr);

                str = str.replace(/</g, "&gl;");
                str = str.replace(/\>/g, "&gt;");
                xml = XML(str);
            }

            if (xml.name() == null)
            {
                str = str.replace(/\/br/g, "</s><n/><s>");
                str = "<p><s>" + str + "</s></p>";
                xml = XML(str);
            }
            return xml;
        }
    }
}
